#ifndef SHOPWIDGET_H
#define SHOPWIDGET_H

#include <QWidget>
#include <QKeyEvent>
#include <QLabel>

#include "Shop.h"
#include "ShopItemWidget.h"

class GameWidget;

class ShopWidget : public QWidget
{
    Q_OBJECT
    public:
        static const int SIZE = 1;
        static const int SHOPKEY = 96;

        explicit ShopWidget( GameWidget* game_, Shop* shop_ )
            :game(game_), shop(shop_),
            moneyCounter(new QLabel( this ))
        {
            this->setWindowTitle( "The ancient shop of epic epicness" );
            QFont font( "Helvetica" );
            font.setPixelSize( 30 );
            moneyCounter->setFont( font );
            moneyCounter->setSizePolicy( QSizePolicy::Maximum,
                                         QSizePolicy::Maximum );
            initialize();
        }

          // opens shop in case it isn't already open
        void open();

        int getMoney() const { return shop->getMoney(); }

        ~ShopWidget() {
            delete moneyCounter;
            //delete[] items;
            for( int i = 0; i < SIZE; i++ ) {
                if( items[i] ) delete items[i];
            }
        }
    public slots:
          // updates moneyCounter
        void updateLabel();
    protected slots:
        void keyPressEvent( QKeyEvent* event );
    private:
          // amount of money
        int money;

        GameWidget* game;
        Shop* shop;

        ShopItemWidget* items[Shop::SIZE];
        QLabel* moneyCounter;

          // initializes shop items
        void initialize();
};

#endif // SHOPWIDGET_H
